/**
* @description: 775. 全局倒置与局部倒置
* @author hewei
* @date 2022/8/25 15:27
* @version 1.0
*/

public class IsIdealPermutation {

    public boolean isIdealPermutation(int[] nums) {
        int n = nums.length;
        if (n < 3) return true;
        int max = nums[0];
        for (int i = 2; i < n; i++) {
            if (nums[i] > max) return false;
            max = Math.max(max, nums[i - 1]);
        }
        return true;
    }
}
